﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using lcmyjobs.Model;
namespace lcmyjobs.BLL
{
	/// <summary>
	/// offer_user
	/// </summary>
	public partial class offer_user
	{
		private readonly lcmyjobs.DAL.offer_user dal=new lcmyjobs.DAL.offer_user();
		public offer_user()
		{}
		#region  Method
        public int DeleteOffers(string uid)
        {
            return dal.DeleteOffers(uid);
        }
        public int UpdateOfferStatus(string uid, int st)
        {
            return dal.UpdateOfferStatus(uid, st);
        }
        public DataSet PageUserRewardOffer(int atid, int startid, int pagesize, out int count,out int wcount)
        {
            return dal.PageUserRewardOffer(atid, startid, pagesize, out count,out wcount);
        }

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
			return dal.GetMaxId();
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int oid)
		{
			return dal.Exists(oid);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int  Add(lcmyjobs.Model.offer_user model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(lcmyjobs.Model.offer_user model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int oid)
		{
			
			return dal.Delete(oid);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string oidlist )
		{
			return dal.DeleteList(oidlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public lcmyjobs.Model.offer_user GetModel(int oid)
		{
			
			return dal.GetModel(oid);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public lcmyjobs.Model.offer_user GetModelByCache(int oid)
		{
			
			string CacheKey = "offer_userModel-" + oid;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(oid);
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (lcmyjobs.Model.offer_user)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<lcmyjobs.Model.offer_user> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<lcmyjobs.Model.offer_user> DataTableToList(DataTable dt)
		{
			List<lcmyjobs.Model.offer_user> modelList = new List<lcmyjobs.Model.offer_user>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				lcmyjobs.Model.offer_user model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new lcmyjobs.Model.offer_user();
					if(dt.Rows[n]["oid"]!=null && dt.Rows[n]["oid"].ToString()!="")
					{
						model.oid=int.Parse(dt.Rows[n]["oid"].ToString());
					}
					if(dt.Rows[n]["rbh"]!=null && dt.Rows[n]["rbh"].ToString()!="")
					{
					model.rbh=dt.Rows[n]["rbh"].ToString();
					}
					if(dt.Rows[n]["job"]!=null && dt.Rows[n]["job"].ToString()!="")
					{
					model.job=dt.Rows[n]["job"].ToString();
					}
					if(dt.Rows[n]["payid"]!=null && dt.Rows[n]["payid"].ToString()!="")
					{
						model.payid=dt.Rows[n]["payid"].ToString();
					}
					if(dt.Rows[n]["unit"]!=null && dt.Rows[n]["unit"].ToString()!="")
					{
					model.unit=dt.Rows[n]["unit"].ToString();
					}
					if(dt.Rows[n]["offername"]!=null && dt.Rows[n]["offername"].ToString()!="")
					{
					model.offername=dt.Rows[n]["offername"].ToString();
					}
					if(dt.Rows[n]["offerID"]!=null && dt.Rows[n]["offerID"].ToString()!="")
					{
					model.offerID=dt.Rows[n]["offerID"].ToString();
					}
					if(dt.Rows[n]["phone"]!=null && dt.Rows[n]["phone"].ToString()!="")
					{
					model.phone=dt.Rows[n]["phone"].ToString();
					}
					if(dt.Rows[n]["email"]!=null && dt.Rows[n]["email"].ToString()!="")
					{
					model.email=dt.Rows[n]["email"].ToString();
					}
					if(dt.Rows[n]["ismy"]!=null && dt.Rows[n]["ismy"].ToString()!="")
					{
						if((dt.Rows[n]["ismy"].ToString()=="1")||(dt.Rows[n]["ismy"].ToString().ToLower()=="true"))
						{
						model.ismy=true;
						}
						else
						{
							model.ismy=false;
						}
					}
					if(dt.Rows[n]["offertime"]!=null && dt.Rows[n]["offertime"].ToString()!="")
					{
						model.offertime=DateTime.Parse(dt.Rows[n]["offertime"].ToString());
					}
					if(dt.Rows[n]["status"]!=null && dt.Rows[n]["status"].ToString()!="")
					{
						model.status=int.Parse(dt.Rows[n]["status"].ToString());
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

